/**
 * 
 */
package com.aspire.android.heliar.preferences;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;

/**
 * @author panglei
 * 
 */
public class Preferences {

	public static final String PREF_IS_FIRST_RUN = "PREF_IS_FIRST_RUN";
	
	private static Preferences preferences = null;
	private static String PREFERENCES_NAME = "Heliar_Preferences";
	private Activity activity;

	private Preferences(Context context) {
		this.activity = (Activity) context;
	}

	public static Preferences getInstance(Context context) {
		if (preferences == null) {
			preferences = new Preferences(context);
		}
		return preferences;
	}
	
	public String getPreference(String name) {
		SharedPreferences settings = activity.getSharedPreferences(PREFERENCES_NAME, 0);
		return settings.getString(name, null);
	}
	
	public void setPreference(String name, String value) {
		SharedPreferences settings = activity.getSharedPreferences(PREFERENCES_NAME, 0);
	    SharedPreferences.Editor editor = settings.edit();
	    editor.putString(name, value);
	}

}
